package com.zzyl.serve.service.impl;

import java.util.List;

import com.zzyl.nursing.dto.NursingProjectDto;
import com.zzyl.serve.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.zzyl.serve.mapper.NursingProjectMapper;
import com.zzyl.serve.domain.NursingProject;
import com.zzyl.serve.service.INursingProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import java.util.Arrays;
/**
 * 护理项目Service业务层处理
 * 
 * @author zhutao
 * @date 2024-12-27
 */
@Service
public class NursingProjectServiceImpl extends ServiceImpl<NursingProjectMapper, NursingProject> implements INursingProjectService
{
    @Autowired
    private NursingProjectMapper nursingProjectMapper;

    /**
     * 查询护理项目
     * 
     * @param id 护理项目主键
     * @return 护理项目
     */
    @Override
    public NursingProject selectNursingProjectById(Long id)
    {
        return getById(id);
    }

    /**
     * 查询护理项目列表
     * 
     * @param nursingProject 护理项目
     * @return 护理项目
     */
    @Override
    public List<NursingProject> selectNursingProjectList(NursingProject nursingProject)
    {
        return nursingProjectMapper.selectNursingProjectList(nursingProject);
    }

    /**
     * 新增护理项目
     * 
     * @param nursingProject 护理项目
     * @return 结果
     */
    @Override
    @CacheEvict(cacheNames = "nursingProject", allEntries = true)
    public int insertNursingProject(NursingProject nursingProject)
    {
        return save(nursingProject) ? 1 : 0;
    }

    /**
     * 修改护理项目
     * 
     * @param nursingProject 护理项目
     * @return 结果
     */
    @Override
    @CacheEvict(cacheNames = "nursingProject", allEntries = true)
    public int updateNursingProject(NursingProject nursingProject)
    {
        return updateById(nursingProject) ? 1 : 0;
    }



    /**
     * 删除护理项目信息
     * 
     * @param id 护理项目主键
     * @return 结果
     */
    @Override
    @CacheEvict(cacheNames = "nursingProject", allEntries = true)
    public int deleteNursingProjectById(Long id)
    {
        return removeById(id) ? 1 : 0;
    }

    @Override
    @Cacheable(cacheNames = "nursingProject")
    public List<NursingProjectVo> selectAll() {
        return nursingProjectMapper.selectAll();
    }

    //查询护理项目列表全部字段
    @Override
    public List<NursingProjectDto> selectNursingProjectDtoList(NursingProject nursingProject) {
        return nursingProjectMapper.selectNursingProjectDtoList(nursingProject);
    }

    //通过id查询单个护理项目的全部字段
    @Override
    public NursingProjectDto selectNursingProjectDotById(Long id) {
        return nursingProjectMapper.selectNursingProjectDotById(id);
    }
}
